home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 February / enter-2006-02.iso / files / Illustrator_CS2_ue_TryOut.exe / bridge / Adobe Bridge 1.0.msi / Data1.cab / _1startup.jsx < prev    next >
Encoding:
Text File  |  2005-03-24  |  4.5 KB  |  148 lines

  1. /**************************************************************************
  2. *
  3. *  @@@BUILDINFO@@@ 01startup.jsx 1.0.0.50 17-Feb-2005
  4. *  Copyright 2005 Adobe Systems Incorporated
  5. *  All Rights Reserved.
  6. *
  7. * NOTICE:  All information contained herein is, and remains the property of
  8. * Adobe Systems Incorporated  and its suppliers,  if any.  The intellectual 
  9. * and technical concepts contained herein are proprietary to  Adobe Systems 
  10. * Incorporated  and its suppliers  and may be  covered by U.S.  and Foreign 
  11. * Patents,patents in process,and are protected by trade secret or copyright 
  12. * law.  Dissemination of this  information or reproduction of this material
  13. * is strictly  forbidden  unless prior written permission is  obtained from 
  14. * Adobe Systems Incorporated.
  15. **************************************************************************/
  16.  
  17. // enable very simple message logging
  18.  
  19. BridgeTalk.log = false;
  20.  
  21. // Initialzie the JavaScript environment during startup.
  22.  
  23. app.onStartup = function (shiftPressed)
  24. {
  25.     // Load the known apps into the main window's apps listbox
  26.     window.loadApps();
  27.     // Create the own debugger
  28.     Debugger.createOwn();
  29.  
  30.     // Load the preferences file if present and SHIFT has not been pressed.
  31.     // This file has been defined by writePrefs() during app shutdown.
  32.     var prefsLoaded = false;
  33.     if (!shiftPressed)
  34.     {
  35.         prefsLoaded = prefs.load();
  36.         // also load the config.jsx file
  37.         try
  38.         {
  39.             var config = new File (app.configFolder + "/config.jsx");
  40.             if (config.exists)
  41.                 app.load (config);
  42.         }
  43.         catch (ignore) {}
  44.     }
  45.     // Connect the own debugger, but save the prefs target and engine
  46.     Debugger.connect (BridgeTalk.appSpecifier);
  47.     // wait until we are connected (should not take long)
  48.     var then = new Date;
  49.     while (!currentDebugger)
  50.     {
  51.         BridgeTalk.pump();
  52.         var now = new Date;
  53.         if ((now - then) > 50000)
  54.         {
  55.             // fatal script error, should never happen (therefore, no ZString)
  56.             errorBox ("FATAL ERROR: Cannot initialize.\nExiting.");
  57.             return false;
  58.         }
  59.     }
  60.  
  61.     // Setup various panes whse contents may depend on the prefs or config data.
  62.     window.variables.setup();
  63.  
  64.     // At this point, also a remote connect message should have been processed.
  65.     // The current debugger should be the one to use.
  66.  
  67.     if (!prefsLoaded)
  68.         // no prefs? start with a blank document
  69.         Document.create();
  70.  
  71.     // Reflect the settings in the menu
  72.     editMenu.lines.checked    = prefs.lineNumbers;
  73.     editMenu.hilite.checked = prefs.hilite;
  74.     debugMenu.reflectState();
  75.     documents.setProfDisplayMode (prefs.profDisplayMode);
  76.     
  77.     // Create the timer function that checks for the presence of a 
  78.     // debugging target every 5 seconds
  79.     scheduleTargetChecker();
  80.  
  81.     // and print the ExtendScript version
  82.     if ($.version.indexOf ("debug") >= 0)
  83.         print ("ExtendScript " + $.version);
  84.  
  85.     // If app and engine have been saved, try to switch there
  86.     if (prefs.target && prefs.engine)
  87.     {
  88.         // If the current debugger is our own, and the prefs setting is not,
  89.         // switch to that app
  90.         if (currentDebugger == ownDebugger && prefs.target != BridgeTalk.appSpecifier)
  91.         {
  92.             window.selectAppAndEngine (prefs.target, prefs.engine);
  93.             if (prefs.target && BridgeTalk.launchTarget (prefs.target))
  94.                 Debugger.connect (prefs.target);
  95.         }
  96.     }
  97.     return true;
  98. }
  99.  
  100. // Create or reschedule the target checker task
  101.  
  102. var taskID = 0;    // the task ID
  103.  
  104. function scheduleTargetChecker (seconds)
  105. {
  106.     if (!seconds)
  107.         seconds = 2;
  108.     if (taskID)
  109.         app.cancelTask (taskID);
  110.     taskID = app.scheduleTask ("BridgeTalk.checkTargets()", seconds * 1000, true);
  111. }
  112.  
  113. // Global Alert box that is localizable and displays an error title
  114.  
  115. function messageBox (msg)
  116. {
  117.     if (msg [0] == "$")
  118.         msg = localize.apply (this, arguments);
  119.     alert (msg, window.title);
  120. }
  121.  
  122. // Global Error box that is localizable and displays an error title
  123.  
  124. function errorBox (msg)
  125. {
  126.     var target = window.title;
  127.     if (currentDebugger && currentDebugger.active)
  128.         target = BridgeTalk.getDisplayName (currentDebugger.target);
  129.     var title = localize ("$$$/ESToolkit/Alerts/ErrorTitle=%1 Error", target);
  130.     if (msg [0] == "$")
  131.         msg = localize.apply (this, arguments);
  132.     alert (msg, title, true);
  133. }
  134.  
  135. // Global Confirm box that is localizable and displays the right title
  136.  
  137. function queryBox (msg)
  138. {
  139.     var target = window.title;
  140.     if (currentDebugger)
  141.         target = BridgeTalk.getDisplayName (currentDebugger.target);
  142.     var title = localize ("$$$/ESToolkit/Alerts/ErrorTitle=%1 Error", target);
  143.     if (msg [0] == "$")
  144.         msg = localize.apply (this, arguments);
  145.     return confirm (msg, false, target);
  146. }
  147.  
  148.